package org.vergil.core.designpattern.vistor;

import java.util.ArrayList;

/**
 * Created by vergil on 17-3-25.
 */
public class EmployeeList {
    //定义一个集合用于存储员工对象
    private ArrayList<AbstractEmployee> list = new ArrayList<AbstractEmployee>();

    public void addEmployee(AbstractEmployee employee) {
        list.add(employee);
    }

    //遍历访问员工集合中的每一个员工对象
    public void accept(AbstractDepartment handler) {
        for (Object obj : list) {
            ((AbstractEmployee) obj).accept(handler);
        }
    }
}
